{% extends "base.html" %}

{% block title %}我的股票走势图{% endblock %}


{% block page_content %}
{% for message in get_flashed_messages() %}
<div class="alert alert-warning">
     <button type="button" class="close" data-dismiss="alert">&times;</button>
     {{ message }}
 </div>
{% endfor %}
<body>
     <div id="form-div">
         <form id="form1" onsubmit="return false" action="#" method="post">
             <p id="p1">股票名称：
                 <input name="stockName" type="text" id="stockName" tabindex="1" size="16" value="" placeholder="股票名称"/>
<!--                 <input type="button" onclick="add1();" value="添加" />-->
             </p>
             <p id="p2">查询时间：
                 <input name="queryTime" type="text" id="queryTime" tabindex="2" size="16" value="" placeholder="输入30查询近30天数据"/>
             </p>
             <p><input type="submit" value="查询" onclick="getData()"></p>
         </form>
     </div>

     
    <div id="FullChart" style="width:1000px; height:600px;"></div>
    <script>
        $(
            function () {
                var chart = echarts.init(document.getElementById('FullChart'), 'white', {renderer: 'canvas'});
                $.ajax({
                    type: "GET",
                    url: "http://127.0.0.1:5000/FullChart",
                    dataType: 'json',
                    success: function (result) {
                        chart.setOption(result);
                    }
                });
            }
        );
        function getData() {
            var chart = echarts.init(document.getElementById('FullChart'), 'white', {renderer: 'canvas'});
            $.ajax({
                type: "POST",//方法类型
                dataType: "json",//预期服务器返回的数据类型
                url: "/FullChart" ,//url
                data: $('#form1').serialize(),
                success: function (result) {
                    chart.setOption(result);
                },
                error: function(err) {
                    if (err.status === 403) {
                        alert("请先登陆系统！");
                    }
                    else {
                        alert("错误的股票代码！");
                    }
                }
            });
        }
        function add1(){
            var input1 = document.createElement('input');
            input1.setAttribute('type', 'text');
            input1.setAttribute('name', 'organizers[]');

            var btn1 = document.getElementById("p1");
            //btn1.insertBefore(input1,null);
            btn1.appendChild(input1);
        }
    </script>
</body>
{% endblock %}

{% block scripts %}
{{ super() }}
    <script src="https://cdn.bootcss.com/jquery/3.0.0/jquery.min.js"></script>
    <script type="text/javascript" src="https://assets.pyecharts.org/assets/echarts.min.js"></script>
{% endblock %}
